home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / utils / index / index.c next >
Encoding:
C/C++ Source or Header  |  1992-12-26  |  1.7 KB  |  79 lines

  1. #include <exec/exec.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. void sr(char *s);
  6.  
  7. char InF[200];
  8. char InF1[200];
  9. char OutF[200];
  10. main(int argc,char *argv[])
  11. {
  12.   char image1[150],image2[150];
  13.   int broke=0;
  14.   int count=1;
  15.   FILE *fi,*fi2,*fo;
  16.   if(argc!=3)
  17.   {
  18.      printf("Index version 1.0, written by Joseph Hodge\n");
  19.      printf("usage: Index <indexname> <form>\n");
  20.      exit(0);
  21.   }
  22.   strcpy(InF,argv[1]); sr(InF);
  23.   strcpy(InF1,argv[2]); sr(InF1);
  24.   sprintf(OutF,"%s.fin",InF);
  25.   
  26.   fi=fopen(InF,"r");
  27.   if(fi==NULL)
  28.   {
  29.     printf("Error, can't open file %s\n",InF);
  30.     exit(0);
  31.   }
  32.   fo=fopen(OutF,"w");
  33.   while(fgets(image1,150,fi)!=NULL)
  34.   {
  35. fprintf(fo,"\n");                                                                          
  36. fprintf(fo,"                      AMIEXPRESS VALIDATION FORM 1.0                           \n");
  37. fprintf(fo,"=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  \n");
  38.  
  39.      printf("Processing Image %d\n",count++);
  40.      fi2=fopen(InF1,"r");
  41.      if(fi2==NULL)
  42.      {
  43.        printf("Error, can't open file %s\n",InF1);
  44.        fclose(fi);
  45.        exit(0);
  46.      }
  47.      while(fgets(image2,150,fi2)!=NULL)
  48.      {
  49.        sr(image2);
  50.        if(!strnicmp(image1,image2,39))
  51.        {
  52.           fprintf(fo,"%s\n",image2);
  53.           while(fgets(image2,150,fi2)!=NULL)
  54.           {
  55.             sr(image2);
  56.           if(strstr("AMIEXPRESS VALIDATION FORM",image2)){ broke=1;break; }
  57.              fprintf(fo,"%s\n",image2);
  58.              broke=0;
  59.           }
  60.           break;
  61.        }
  62.      }
  63.      fclose(fi2);
  64.   }
  65.   fclose(fi);
  66.   fclose(fo);
  67.   exit(0);
  68. }
  69.  
  70. void sr(char *s)
  71. {
  72.   register int i;
  73.   i=strlen(s)-1;
  74.   while(i>-1)
  75.   {
  76.     if(*(s+i)<=32) *(s+i)='\0'; else break;
  77.     i--;
  78.   }
  79. }